<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page import="com.sxp.dao.RoleEnum" %>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.lang.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<script src="jqueryCalendar/jquery-1.6.2.min.js"></script>
<script src="jqueryCalendar/jquery-ui-1.8.15.custom.min.js"></script>
<link rel="stylesheet" href="jqueryCalendar/jqueryCalendar.css">
<script src="js/JQueryCalendar.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/list_food_selection.css" rel="stylesheet">



<title>Show All FoodDetails</title>
</head>
<body >
<div class="container">
<%
String getUrlDate=request.getParameter("SDate");
DateFormat sd=new SimpleDateFormat("yyyy-MM-dd");

java.util.Date dateS=sd.parse(getUrlDate);
pageContext.setAttribute("urlD",dateS);
%>
<jsp:include page="menu.jsp">
<jsp:param value="d" name="accessRole" />
</jsp:include>

      <div id="display">

          <table border=1 id="resultTable" class="table table-bordered table-condensed table-bordered">

                  <thead>
                     <tr>
                     <th>Name</th>
                     <th>RiceType</th>
                     <c:forEach items="${mealL}" var="ml" >
                     <th><c:out value="${ml.mealType}"/></th>
                     </c:forEach>
                     <th>Edit</th>
                     </tr>
                  </thead>
                  <tbody>
                    <c:forEach var="i" begin="1" end="${dateS.size()}">
                        <form action="DailyFoodController?action=update" method="post"  >
                         <tr>
                             <td><c:out value="${dateS.get(i-1).userName}" /></td>
                             <c:choose>
                             <c:when test="${not empty dateS.get(i-1).date}" >
                                <td>
                                <select name="riceType" id="riceType">
                                <c:forEach items="${riceL}" var="rl">
                                    <option value="${rl.riceId}" <c:if test="${dateS.get(i-1).riceId==rl.riceId}">selected</c:if>><c:out value="${rl.riceType}"/></option>
                                </c:forEach>
                                </select>
                                </td>
                                <c:forEach  items="${mealL}" var="ml" >
                                    <td><span class="ms-RadioText"><input name="meal${i}" id="meal${i}" type="radio" value="${ml.mealId}" <c:if test="${dateS.get(i-1).mealId ==ml.mealId}">checked</c:if>></span></td>
                                </c:forEach>
                             </c:when>
                             <c:otherwise>
                             <td>
                                <select name="riceType" id="riceType">
                                <c:forEach items="${riceL}" var="rl">
                                    <option  value="${rl.riceId}"  <c:if test="${rl.riceId == 0}">selected</c:if>><c:out value="${rl.riceType}"/></option>
                                </c:forEach>
                                </select>
                             </td>
                             <c:forEach items="${mealL}" var="ml">
                                <td><span class="ms-RadioText"><input name="meal${i}" id="meal${i}" type="radio" value="${ml.mealId}"  <c:if test="${ml.mealId == 4}">checked</c:if>></span></td>
                             </c:forEach>
                             </c:otherwise>
                             </c:choose>
                             </td>
                             <td>
                             <jsp:useBean id="now" class="java.util.Date"/>
                             <c:choose>
                                <c:when test="${urlD lt now}">
                                    <input type="submit"  id="disable" value="Save" name="Save" disabled="disabled"/>
                                </c:when>
                                <c:otherwise>
                                     <input type="submit"  value="Save" name="Save" class="btn btn-primary btn-xs"/>
                                     <input type="hidden" name="user" value="${dateS.get(i-1).userName}">
                                     <input type="hidden" name="selDate" value="<%= getUrlDate%>">
                                     <input type="hidden" name="size" value="${dateS.size()}">
                                     <input type="hidden" name="ithVal" value="${i}">
                                     <input type="hidden" name="SDate" value="<%= getUrlDate%>">
                                </c:otherwise>
                              </c:choose>
                              </td>
                         </tr>
                        </form>
                    </c:forEach>
                  </tbody>
          </table>

      </div>
</div>
</body>
</html>
